#ifndef UTIL_H
#define UTIL_H

#include <fstream>

#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define MIDIFILE_SWAP32(x) x = ((x & 0xFF) << 24) | ((x & 0xFF00) << 8) | ((x & 0xFF0000) >> 8) | ((x & 0xFF000000) >> 24)
#define MIDIFILE_SWAP16(x) x = ((x & 0xFF) << 8) | ((x & 0xFF00) >> 8)
#else
#define MIDIFILE_SWAP32(x)
#define MIDIFILE_SWAP16(x)
#endif

int readVariableLength(std::ifstream &file) throw ();
void extendAllocation(char* &data, int length, int &allocLength) throw (std::bad_alloc);

#endif /* UTIL_H */
